//input textarea弹回
//input
var u = navigator.userAgent;
var isPc=isPcOS()
var isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
//isIOS&&!isPc
if(isIOS&&!isPc) {//下面这个方法只适合在微信端使用
	document.body.addEventListener("click", function(e) {
		if(e.target.nodeName == "INPUT"||e.target.nodeName == "SELECT") {
			if(e.target.type == "text" ||e.target.type == "number" || e.target.type == "password"||e.target.nodeName == "SELECT") {
				e.target.onblur = function() {
					setTimeout(function() {
						var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
						window.scrollTo(0, Math.max(scrollHeight - 0.01, 0));
					}, 150);
				}
			}
		} else if(document.activeElement.tagName == "TEXTAREA") {
			e.target.onfocus = function () {
				//{behavior: "auto", block: "center", inline: "start"}
				//document.activeElement.scrollIntoView();
			}
			e.target.onblur = function() {
				//让输入框居中显示
//				setTimeout(()=>{
//					document.activeElement.scrollIntoView();
//				},10)
				//这个解决很不错
				setTimeout(function() {
					var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
					window.scrollTo(0, Math.max(scrollHeight - 0.01, 0));
				}, 150);
			}
		}
	})
}
//setTimeout模拟setInterval
function setFun() {
	setInt = setTimeout(function() {
		var scrollHeight = document.documentElement.scrollTop || document.body.scrollTop || 0;
		window.scrollTo(0, Math.max(scrollHeight - 0.01, 0));
		count += 20
		if(count >= 200) {
			clearTimeout(setInt)
		} else {
			setFun();
		}
	}, 20);
}

//获取是否PC端
function isPcOS() {
	var isWin = (navigator.platform == "Win32") || (navigator.platform == "Windows");
	if(isWin) return true; //'Win'
	var isMac = (navigator.platform == "Mac68K") || (navigator.platform == "MacPPC") || (navigator.platform == "Macintosh") || (navigator.platform == "MacIntel");
	if(isMac) return true; //'Mac'
	var isUnix = (navigator.platform == "X11") && !isWin && !isMac;
	if(isUnix) return true; //'Unix'
	var isLinux = (String(navigator.platform).indexOf("Linux") > -1);
	if(isLinux) return true; //'Linux'
}